﻿#Region "License & Usage"

'Microsoft Public License (Ms-PL) 

'This license governs use of the accompanying software. If you use the 
'software, you accept this license. If you do not accept the license, do 
'not use the software. 

'1. Definitions 

'The terms "reproduce," "reproduction," "derivative works," and 
'"distribution" have the same meaning here as under U.S. copyright law. 

'A "contribution" is the original software, or any additions or changes 
'to the software. 

'A "contributor" is any person that distributes its contribution under 
'this license. 

'"Licensed patents" are a contributor's patent claims that read directly 
'on its contribution. 

'2. Grant of Rights 

'(A) Copyright Grant- Subject to the terms of this license, including the 
'license conditions and limitations in section 3, each contributor grants 
'you a non-exclusive, worldwide, royalty-free copyright license to 
'reproduce its contribution, prepare derivative works of its 
'contribution, and distribute its contribution or any derivative works 
'that you create. 

'(B) Patent Grant- Subject to the terms of this license, including the 
'license conditions and limitations in section 3, each contributor grants 
'you a non-exclusive, worldwide, royalty-free license under its licensed 
'patents to make, have made, use, sell, offer for sale, import, and/or 
'otherwise dispose of its contribution in the software or derivative 
'works of the contribution in the software. 

'3. Conditions and Limitations 

'(A) No Trademark License- This license does not grant you rights to use 
'any contributors' name, logo, or trademarks. 

'(B) If you bring a patent claim against any contributor over patents 
'that you claim are infringed by the software, your patent license from 
'such contributor to the software ends automatically. 

'(C) If you distribute any portion of the software, you must retain all 
'copyright, patent, trademark, and attribution notices that are present 
'in the software. 

'(D) If you distribute any portion of the software in source code form, 
'you may do so only under this license by including a complete copy of 
'this license with your distribution. If you distribute any portion of 
'the software in compiled or object code form, you may only do so under a 
'license that complies with this license. 

'(E) The software is licensed "as-is." You bear the risk of using it. The 
'contributors give no express warranties, guarantees or conditions. You 
'may have additional consumer rights under your local laws which this 
'license cannot change. To the extent permitted under your local laws, 
'the contributors exclude the implied warranties of merchantability, 
'fitness for a particular purpose and non-infringement.

#End Region

#Region "Options"

Option Strict On
Option Explicit On

#End Region

#Region "Imports"

'From .Net Framework 3.5
Imports Microsoft.Drawing
Imports System.Drawing
Imports System.IO
Imports System.Windows.Forms

'From Custom Classes/Reference
Imports StedySoft.SenseSDK
Imports StedySoft.SenseSDK.DrawingCE
Imports SenseSDKExtended.DrawingCEEx

#End Region

''' <summary>SensePanelLinkLabel</summary>
''' <author>Greenhacks</author>
''' <author-reference>None</author-reference>
''' <copyright>None</copyright>
''' <version>0.1</version>
''' <remarks>None</remarks>
''' <reference>None</reference>
<CLSCompliant(True)> _
Public Class SensePanelLinkLabel
    Inherits SensePanelBase
    Implements IDisposable

#Region "Fields"

    'General Flags
    Private _disposed As Boolean = False

    'General Properties
    Private _name As String = Nothing
    Private _backColor As System.Drawing.Color = Nothing

    'PrimaryText Properties
    Private _primaryText As String = Nothing
    'Private _primaryTextLineHeight As Integer = Nothing
    'Private _primaryTextLineWidth As Integer = Nothing
    Private _primaryTextFontName As String = "Tahoma" '"Helvetica Neue OTS"
    Private _primaryTextFontSize As Single = 9.0F
    Private _primaryTextFontStyle As System.Drawing.FontStyle = FontStyle.Regular
    Private _primaryTextForeColor As System.Drawing.Color = Color.Black
    Private _primaryTextBackColor As System.Drawing.Color = Color.Gray
    Private _primaryTextAlignment As System.Drawing.StringAlignment = StringAlignment.Near

    'URLText Properties
    Private _urlTextText As String = Nothing
    'Private _urlTextTextLineHeight As Integer = Nothing
    'Private _urlTextTextLineWidth As Integer = Nothing
    Private _urlTextTextFontName As String = "Tahoma" '"Helvetica Neue OTS"
    Private _urlTextTextFontSize As Single = 7.0F
    Private _urlTextTextFontStyle As System.Drawing.FontStyle = FontStyle.Regular
    Private _urlTextTextForeColor As System.Drawing.Color = Color.Black
    Private _urlTextTextBackColor As System.Drawing.Color = Color.Gray
    Private _urlTextTextAlignment As System.Drawing.StringAlignment = StringAlignment.Near

    'Global 
    Private _primaryTextModified As String = Nothing
    Private _urlTextTextModified As String = Nothing
    Private _primaryTextCharsCount As Integer = 24
    Private _urlTextTextCharsCount As Integer = 24

    'Hold Images
    Private _iThumbnailLeft As Microsoft.Drawing.IImage = Nothing
    Private _iThumbnailRight As Microsoft.Drawing.IImage = Nothing

    'Hold Cordinates
    Private _iThumbnailLeftLocationX As Double = 0
    Private _iThumbnailLeftLocationY As Double = 0
    Private _iThumbnailRightLocationX As Double = 0
    Private _iThumbnailRightLocationY As Double = 0
    Private _primaryTextLocationX As Double = 0
    Private _primaryTextLocationY As Double = 0
    Private _urlTextTextLocationX As Double = 0
    Private _urlTextTextLocationY As Double = 0

    Private _myCurrentPosition As Integer = 0

    'Hold Sizes
    Private _iThumbnailLeftSize As Size = Nothing
    Private _iThumbnailRightSize As Size = Nothing
    Private _primaryTextSize As Size = Nothing
    Private _urlTextTextSize As Size = Nothing

    'Hold Margins
    Private _iThumbnailLeftMarginLR As Double = 0
    Private _iThumbnailLeftMarginTB As Double = 0
    Private _iThumbnailRightMarginLR As Double = 0
    Private _iThumbnailRightMarginTB As Double = 0

#End Region

#Region "Events"

    ''' <summary>
    ''' OnClick Event
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <remarks>General Control OnClick Event</remarks>
    Public Shadows Event OnClick(ByVal sender As Object)

    ''' <summary>
    ''' OnClickiThumbnailLeft Event
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <remarks></remarks>
    Public Event OnClickiThumbnailLeft(ByVal sender As Object)

    ''' <summary>
    ''' OnClickiThumbnailRight Event
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <remarks></remarks>
    Public Event OnClickiThumbnailRight(ByVal sender As Object)

    ''' <summary>
    ''' OnControlMoved Event
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="Y"></param>
    ''' <remarks>Fires when a control is scrolled in the list</remarks>
    Public Event OnControlMoved(ByVal sender As Object, ByVal Y As Integer)

#End Region

#Region "Methods"

    ''' <summary>
    ''' Constructor
    ''' </summary>
    ''' <remarks>None</remarks>
    Public Sub New()

        Try

            'Do Nothing

        Catch ex As Exception

            'Throw exception if any other error caught
            Throw New Exception(ex.Message)

        End Try

    End Sub

    ''' <summary>
    ''' Constructor
    ''' </summary>
    ''' <remarks>None</remarks>
    Public Sub New(ByVal Name As String)

        Try

            'Save name property
            _name = Name

        Catch ex As Exception

            'Throw exception if any other error caught
            Throw New Exception(ex.Message)

        End Try

    End Sub

    ''' <summary>
    ''' Dispose
    ''' </summary>
    ''' <remarks>None</remarks>
    Public Overrides Sub Dispose()

        Try

            Me._dispose(True)
            GC.SuppressFinalize(Me)
            MyBase.Dispose()

        Catch ex As Exception

            'Throw exception if any other error caught
            Throw New Exception(ex.Message)

        End Try

    End Sub

    ''' <summary>
    ''' _Dispose
    ''' </summary>
    ''' <param name="disposing"></param>
    ''' <remarks>None</remarks>
    Private Sub _dispose(ByVal disposing As Boolean)

        Try

            Me._disposed = True

        Catch ex As Exception

            'Throw exception if any other error caught
            Throw New Exception(ex.Message)

        End Try
    End Sub

    ''' <summary>
    ''' Check if it is VGA or QVGA
    ''' </summary>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Private Function _isVGA() As Boolean

        Try

            'Return the output
            Return StedySoft.SenseSDK.DrawingCE.Resolution.ScreenIsVGA

        Catch ex As Exception

            'Throw exception if any other error caught
            Throw New Exception(ex.Message)

        End Try

    End Function

    ''' <summary>
    ''' OnMouseDown Event
    ''' </summary>
    ''' <param name="x"></param>
    ''' <param name="y"></param>
    ''' <param name="cancelScroll"></param>
    ''' <remarks></remarks>
    Public Overrides Sub OnMouseDown(ByVal x As Integer, ByVal y As Integer, ByRef cancelScroll As Boolean)
        MyBase.OnMouseDown(x, y, cancelScroll)

        'Record current control position Y
        _myCurrentPosition = MyBase.ClientRectangle.Y

    End Sub

    ''' <summary>
    ''' OnMouseUp Event
    ''' </summary>
    ''' <param name="x"></param>
    ''' <param name="y"></param>
    ''' <remarks></remarks>
    Public Overrides Sub OnMouseUp(ByVal x As Integer, ByVal y As Integer)
        MyBase.OnMouseUp(x, y)

        'Check controls current position
        If Not MyBase.ClientRectangle.Y = _myCurrentPosition Then

            'Raise OnControlMoved Event
            RaiseEvent OnControlMoved(Me, MyBase.ClientRectangle.Y)

            'Then exit sub to avoid raising other events
            Exit Sub

        End If

        'Raise OnClick Event before other events first
        RaiseEvent OnClick(Me)

        'Hold Mouse click cordinates
        Dim mousePoint As System.Drawing.Point = System.Windows.Forms.Control.MousePosition()
        Dim pointX As Integer = mousePoint.X - MyBase.ClientRectangle.X
        Dim pointY As Integer = mousePoint.Y - MyBase.ClientRectangle.Y

        If Not _iThumbnailLeft Is Nothing Then

            Select Case pointX

                Case CInt(_iThumbnailLeftLocationX) To _iThumbnailLeftSize.Width

                    'Raise OnClickiThumbnailLeft Event
                    RaiseEvent OnClickiThumbnailLeft(Me)

                    Exit Sub

            End Select

        End If

        If Not _iThumbnailRight Is Nothing Then

            Select Case pointX

                Case CInt(_iThumbnailRightLocationX) To _iThumbnailRightSize.Width

                    'Raise OnClickiThumbnailRight Event
                    RaiseEvent OnClickiThumbnailRight(Me)

                    Exit Sub

            End Select

        End If

        If Not _urlTextText Is Nothing Then

            Dim _processStartInfo As New ProcessStartInfo("IExplore.exe", _urlTextText)
            Process.Start(_processStartInfo)

        End If

    End Sub

    ''' <summary>
    ''' DrawContent
    ''' </summary>
    ''' <param name="g"></param>
    ''' <remarks></remarks>
    Public Sub DrawContent(ByVal g As System.Drawing.Graphics)

        Dim _controlRectangle As Rectangle = New Rectangle(ClientRectangle.Left, ClientRectangle.Top, ClientRectangle.Width, ClientRectangle.Height)

        If Not _backColor = Nothing Then
            DrawBackColor(_backColor, _controlRectangle, g)
        End If


    End Sub

    ''' <summary>
    ''' DrawBackColor
    ''' </summary>
    ''' <param name="__BackColor"></param>
    ''' <param name="__Rectangle"></param>
    ''' <param name="g"></param>
    ''' <remarks></remarks>
    Public Sub DrawBackColor(ByVal __BackColor As System.Drawing.Color, ByVal __Rectangle As Rectangle, ByVal g As System.Drawing.Graphics)

        'Draw background color
        g.FillRectangle(New SolidBrush(__BackColor), __Rectangle)

    End Sub

    ''' <summary>
    ''' Draw_HTCContactsStyle1
    ''' </summary>
    ''' <param name="g"></param>
    ''' <remarks></remarks>
    Public Sub Draw_HTCContactsStyle1(ByVal g As System.Drawing.Graphics)

        If Not _iThumbnailLeft Is Nothing Then

            _iThumbnailLeftSize = SenseAPIs.SenseImage.GetIImageSize(_iThumbnailLeft)
            _iThumbnailLeftLocationX = (ClientRectangle.Height - _iThumbnailLeftSize.Height) / 2
            _iThumbnailLeftLocationY = ClientRectangle.Top + (ClientRectangle.Height - _iThumbnailLeftSize.Height) / 2
            _iThumbnailLeftMarginTB = (ClientRectangle.Height - _iThumbnailLeftSize.Height) / 2
            _iThumbnailLeftMarginLR = (ClientRectangle.Height - _iThumbnailLeftSize.Height) / 2

            Dim ___iThumbnailLeft As IImage = _iThumbnailLeft
            g.DrawImageAlphaChannel(___iThumbnailLeft, New Rectangle(CInt(_iThumbnailLeftLocationX), CInt(_iThumbnailLeftLocationY), _iThumbnailLeftSize.Width, _iThumbnailLeftSize.Height))

        End If

        If Not _iThumbnailRight Is Nothing Then

            _iThumbnailRightSize = SenseAPIs.SenseImage.GetIImageSize(_iThumbnailRight)
            _iThumbnailRightLocationX = Screen.PrimaryScreen.Bounds.Width - (_iThumbnailRightSize.Width + ((ClientRectangle.Height - _iThumbnailRightSize.Height) / 2))
            _iThumbnailRightLocationY = ClientRectangle.Top + (ClientRectangle.Height - _iThumbnailRightSize.Height) / 2
            _iThumbnailRightMarginTB = (ClientRectangle.Height - _iThumbnailRightSize.Height) / 2
            _iThumbnailRightMarginLR = _iThumbnailRightMarginTB / 2

            Dim ___iThumbnailRight As IImage = _iThumbnailRight
            g.DrawImageAlphaChannel(___iThumbnailRight, New Rectangle(CInt(_iThumbnailRightLocationX), CInt(_iThumbnailRightLocationY), _iThumbnailRightSize.Width, _iThumbnailRightSize.Height))

        End If

        If _primaryText Is Nothing And _urlTextText Is Nothing Then Exit Sub

        If _iThumbnailLeft Is Nothing And _iThumbnailRight Is Nothing Then

            If _urlTextText Is Nothing Then

                If Not _primaryText = String.Empty Then
                    _primaryTextSize = New Size(Screen.PrimaryScreen.Bounds.Width - If(_isVGA, 20, 10), SenseAPIsEx.SenseStrings.CalculateStringHeight(Left(_primaryText, 10), _primaryTextFontName, CInt(_primaryTextFontSize), _primaryTextFontStyle, New Size(Screen.PrimaryScreen.Bounds.Width - If(_isVGA, 10, 5), ClientRectangle.Height)))
                    _primaryTextLocationX = If(_isVGA, 10, 5)
                    _primaryTextLocationY = ClientRectangle.Top + (ClientRectangle.Height / 2) - (_primaryTextSize.Height / 2)
                End If

            Else

                If Not _primaryText = String.Empty Then
                    _primaryTextSize = New Size(Screen.PrimaryScreen.Bounds.Width - If(_isVGA, 20, 10), CInt(ClientRectangle.Height / 2))
                    _primaryTextLocationX = If(_isVGA, 10, 5)
                    _primaryTextLocationY = ClientRectangle.Top + ((ClientRectangle.Height / 2) / 2) - (SenseAPIsEx.SenseStrings.CalculateStringHeight(Left(_primaryText, 10), _primaryTextFontName, CInt(_primaryTextFontSize), _primaryTextFontStyle, New Size(_primaryTextSize.Width, _primaryTextSize.Height)) / 2)
                End If

                If Not _urlTextText = String.Empty Then
                    _urlTextTextSize = New Size(Screen.PrimaryScreen.Bounds.Width - If(_isVGA, 20, 10), CInt(ClientRectangle.Height / 2))
                    _urlTextTextLocationX = If(_isVGA, 10, 5)
                    _urlTextTextLocationY = (ClientRectangle.Top + (ClientRectangle.Height / 2)) + ((ClientRectangle.Height / 2) / 2) - (SenseAPIsEx.SenseStrings.CalculateStringHeight(Left(_urlTextText, 10), _urlTextTextFontName, CInt(_urlTextTextFontSize), _urlTextTextFontStyle, New Size(_urlTextTextSize.Width, _urlTextTextSize.Height)) / 2)
                End If

            End If

        End If

        If Not _iThumbnailLeft Is Nothing And Not _iThumbnailRight Is Nothing Then

            If _urlTextText Is Nothing Then

                If Not _primaryText = String.Empty Then
                    _primaryTextSize = New Size(CInt(Screen.PrimaryScreen.Bounds.Width - (_iThumbnailLeftLocationX * 2) - _iThumbnailLeftSize.Width - _iThumbnailRightSize.Width - (((Screen.PrimaryScreen.Bounds.Width - _iThumbnailRightLocationX) - _iThumbnailRightSize.Width) * 2)), ClientRectangle.Height)
                    _primaryTextLocationX = _iThumbnailLeftLocationX + _iThumbnailLeftSize.Width + If(_isVGA, 10, 5)
                    _primaryTextLocationY = ClientRectangle.Top + (ClientRectangle.Height / 2) - (SenseAPIsEx.SenseStrings.CalculateStringHeight(Left(_primaryText, 10), _primaryTextFontName, CInt(_primaryTextFontSize), _primaryTextFontStyle, New Size(_primaryTextSize.Width, _primaryTextSize.Height)) / 2)
                End If

            Else

                If Not _primaryText = String.Empty Then
                    _primaryTextSize = New Size(CInt(Screen.PrimaryScreen.Bounds.Width - (_iThumbnailLeftLocationX * 2) - _iThumbnailLeftSize.Width - _iThumbnailRightSize.Width - (((Screen.PrimaryScreen.Bounds.Width - _iThumbnailRightLocationX) - _iThumbnailRightSize.Width) * 2)), CInt(ClientRectangle.Height / 2))
                    _primaryTextLocationX = _iThumbnailLeftLocationX + _iThumbnailLeftSize.Width + If(_isVGA, 10, 5)
                    _primaryTextLocationY = ClientRectangle.Top + ((ClientRectangle.Height / 2) / 2) - (SenseAPIsEx.SenseStrings.CalculateStringHeight(Left(_primaryText, 10), _primaryTextFontName, CInt(_primaryTextFontSize), _primaryTextFontStyle, New Size(_primaryTextSize.Width, _primaryTextSize.Height)) / 2)
                End If

                If Not _urlTextText = String.Empty Then
                    _urlTextTextSize = New Size(CInt(Screen.PrimaryScreen.Bounds.Width - (_iThumbnailLeftLocationX * 2) - _iThumbnailLeftSize.Width - _iThumbnailRightSize.Width - (((Screen.PrimaryScreen.Bounds.Width - _iThumbnailRightLocationX) - _iThumbnailRightSize.Width) * 2)), CInt(ClientRectangle.Height / 2))
                    _urlTextTextLocationX = _iThumbnailLeftLocationX + _iThumbnailLeftSize.Width + If(_isVGA, 10, 5)
                    _urlTextTextLocationY = (ClientRectangle.Top + (ClientRectangle.Height / 2)) + ((ClientRectangle.Height / 2) / 2) - (SenseAPIsEx.SenseStrings.CalculateStringHeight(Left(_urlTextText, 10), _urlTextTextFontName, CInt(_urlTextTextFontSize), _urlTextTextFontStyle, New Size(_urlTextTextSize.Width, _urlTextTextSize.Height)) / 2)
                End If

            End If

        End If

        If Not _iThumbnailLeft Is Nothing And _iThumbnailRight Is Nothing Then

            If _urlTextText Is Nothing Then

                If Not _primaryText = String.Empty Then
                    _primaryTextSize = New Size(CInt((Screen.PrimaryScreen.Bounds.Width - _iThumbnailLeftLocationX - _iThumbnailLeftSize.Width) - (If(_isVGA, 10, 5) * 2)), CInt(ClientRectangle.Height))
                    _primaryTextLocationX = _iThumbnailLeftLocationX + _iThumbnailLeftSize.Width + If(_isVGA, 10, 5)
                    _primaryTextLocationY = ClientRectangle.Top + (ClientRectangle.Height / 2) - (SenseAPIsEx.SenseStrings.CalculateStringHeight(Left(_primaryText, 10), _primaryTextFontName, CInt(_primaryTextFontSize), _primaryTextFontStyle, New Size(_primaryTextSize.Width, _primaryTextSize.Height)) / 2)
                End If

            Else

                If Not _primaryText = String.Empty Then
                    _primaryTextSize = New Size(CInt((Screen.PrimaryScreen.Bounds.Width - _iThumbnailLeftLocationX - _iThumbnailLeftSize.Width) - (If(_isVGA, 10, 5) * 2)), CInt(ClientRectangle.Height / 2))
                    _primaryTextLocationX = _iThumbnailLeftLocationX + _iThumbnailLeftSize.Width + If(_isVGA, 10, 5)
                    _primaryTextLocationY = ClientRectangle.Top + ((ClientRectangle.Height / 2) / 2) - (SenseAPIsEx.SenseStrings.CalculateStringHeight(Left(_primaryText, 10), _primaryTextFontName, CInt(_primaryTextFontSize), _primaryTextFontStyle, New Size(_primaryTextSize.Width, _primaryTextSize.Height)) / 2)
                End If

                If Not _urlTextText = String.Empty Then
                    _urlTextTextSize = New Size(CInt(Screen.PrimaryScreen.Bounds.Width - (_iThumbnailLeftLocationX * 2) - _iThumbnailLeftSize.Width - If(_isVGA, 10, 5)), CInt(ClientRectangle.Height / 2))
                    _urlTextTextLocationX = _iThumbnailLeftLocationX + _iThumbnailLeftSize.Width + If(_isVGA, 10, 5)
                    _urlTextTextLocationY = (ClientRectangle.Top + (ClientRectangle.Height / 2)) + ((ClientRectangle.Height / 2) / 2) - (SenseAPIsEx.SenseStrings.CalculateStringHeight(Left(_urlTextText, 10), _urlTextTextFontName, CInt(_urlTextTextFontSize), _urlTextTextFontStyle, New Size(_urlTextTextSize.Width, _urlTextTextSize.Height)) / 2)
                End If

            End If

        End If

        If _iThumbnailLeft Is Nothing And Not _iThumbnailRight Is Nothing Then

            If _urlTextText Is Nothing Then

                If Not _primaryText = String.Empty Then
                    _primaryTextSize = New Size(CInt(Screen.PrimaryScreen.Bounds.Width - _iThumbnailRightSize.Width - (((Screen.PrimaryScreen.Bounds.Width - _iThumbnailRightLocationX) - _iThumbnailRightSize.Width) * 2) - If(_isVGA, 10, 5)), ClientRectangle.Height)
                    _primaryTextLocationX = _iThumbnailLeftLocationX + _iThumbnailLeftSize.Width + If(_isVGA, 10, 5)
                    _primaryTextLocationY = ClientRectangle.Top + (ClientRectangle.Height / 2) - (SenseAPIsEx.SenseStrings.CalculateStringHeight(Left(_primaryText, 10), _primaryTextFontName, CInt(_primaryTextFontSize), _primaryTextFontStyle, New Size(_primaryTextSize.Width, _primaryTextSize.Height)) / 2)
                End If

            Else

                If Not _primaryText = String.Empty Then
                    _primaryTextSize = New Size(CInt(Screen.PrimaryScreen.Bounds.Width - _iThumbnailRightSize.Width - (((Screen.PrimaryScreen.Bounds.Width - _iThumbnailRightLocationX) - _iThumbnailRightSize.Width) * 2) - If(_isVGA, 10, 5)), CInt(ClientRectangle.Height / 2))
                    _primaryTextLocationX = _iThumbnailLeftLocationX + _iThumbnailLeftSize.Width + If(_isVGA, 10, 5)
                    _primaryTextLocationY = ClientRectangle.Top + ((ClientRectangle.Height / 2) / 2) - (SenseAPIsEx.SenseStrings.CalculateStringHeight(Left(_primaryText, 10), _primaryTextFontName, CInt(_primaryTextFontSize), _primaryTextFontStyle, New Size(_primaryTextSize.Width, _primaryTextSize.Height)) / 2)
                End If

                If Not _urlTextText = String.Empty Then
                    _urlTextTextSize = New Size(CInt(Screen.PrimaryScreen.Bounds.Width - _iThumbnailRightSize.Width - (((Screen.PrimaryScreen.Bounds.Width - _iThumbnailRightLocationX) - _iThumbnailRightSize.Width) * 2)), CInt(ClientRectangle.Height / 2))
                    _urlTextTextLocationX = _iThumbnailLeftLocationX + _iThumbnailLeftSize.Width + If(_isVGA, 10, 5)
                    _urlTextTextLocationY = (ClientRectangle.Top + (ClientRectangle.Height / 2)) + ((ClientRectangle.Height / 2) / 2) - (SenseAPIsEx.SenseStrings.CalculateStringHeight(Left(_urlTextText, 10), _urlTextTextFontName, CInt(_urlTextTextFontSize), _urlTextTextFontStyle, New Size(_urlTextTextSize.Width, _urlTextTextSize.Height)) / 2)
                End If

            End If

        End If

        If Not _primaryText = String.Empty Then
            _primaryTextCharsCount = SenseAPIsEx.SenseStrings.CalculateCharactersCanFit(_primaryText, _primaryTextFontName, CInt(_primaryTextFontSize), _primaryTextFontStyle, New Size(_primaryTextSize.Width, _primaryTextSize.Height), g)
            If _primaryText.Length > _primaryTextCharsCount Then _primaryTextModified = Left(_primaryText, _primaryTextCharsCount) & "..." Else _primaryTextModified = _primaryText
        End If

        If Not _urlTextText = String.Empty Then
            _urlTextTextCharsCount = SenseAPIsEx.SenseStrings.CalculateCharactersCanFit(_urlTextText, _urlTextTextFontName, CInt(_urlTextTextFontSize), _urlTextTextFontStyle, New Size(_urlTextTextSize.Width, _urlTextTextSize.Height), g)
            If _urlTextText.Length > _urlTextTextCharsCount Then _urlTextTextModified = Left(_urlTextText, _urlTextTextCharsCount) & "..." Else _urlTextTextModified = _urlTextText
        End If

        If Not _primaryText = String.Empty Then
            'Draw the Primary text with other properties like height,color,style,alignment,etc
            Using f As Font = New Font(_primaryTextFontName, _primaryTextFontSize, _primaryTextFontStyle)
                Dim s As String = _primaryTextModified
                Dim r As Rectangle = New Rectangle(CInt(_primaryTextLocationX), CInt(_primaryTextLocationY), _primaryTextSize.Width, _primaryTextSize.Height) '(Left,Top,Width,Height)
                Using b As Brush = New SolidBrush(_primaryTextForeColor)
                    Using sf As StringFormat = New StringFormat()
                        sf.Alignment = _primaryTextAlignment
                        g.DrawString(s, f, b, r, sf)
                    End Using
                End Using
            End Using
        End If

        If Not _urlTextText = String.Empty Then
            'Draw the URL text with other properties like height,color,style,alignment,etc
            Using f As Font = New Font(_urlTextTextFontName, _urlTextTextFontSize, _urlTextTextFontStyle)
                Dim s As String = _urlTextTextModified
                Dim r As Rectangle = New Rectangle(CInt(_urlTextTextLocationX), CInt(_urlTextTextLocationY), _urlTextTextSize.Width, _urlTextTextSize.Height) '(Left,Top,Width,Height)
                Using b As Brush = New SolidBrush(_urlTextTextForeColor)
                    Using sf As StringFormat = New StringFormat()
                        sf.Alignment = _urlTextTextAlignment
                        g.DrawString(s, f, b, r, sf)
                    End Using
                End Using
            End Using
        End If

    End Sub

    ''' <summary>
    ''' OnRender
    ''' </summary>
    ''' <param name="g"></param>
    ''' <remarks></remarks>
    Public Overrides Sub OnRender(ByVal g As System.Drawing.Graphics)
        MyBase.OnRender(g)

        DrawContent(g)

        Draw_HTCContactsStyle1(g)

    End Sub

#End Region

#Region "Properties"

    ''' <summary>
    ''' BackColor
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Property BackColor() As System.Drawing.Color
        Get
            Return _backColor
        End Get
        Set(ByVal value As System.Drawing.Color)
            _backColor = value
        End Set
    End Property

    ''' <summary>
    ''' Primary Text
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Property PrimaryText() As String
        Get
            Return _primaryText
        End Get
        Set(ByVal value As String)
            _primaryText = value
        End Set
    End Property

    ''' <summary>
    ''' PrimaryTextFontName
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Property PrimaryTextFontName() As String
        Get
            Return _primaryTextFontName
        End Get
        Set(ByVal value As String)
            _primaryTextFontName = value
        End Set
    End Property

    ''' <summary>
    ''' PrimaryTextFontSize
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Property PrimaryTextFontSize() As Single
        Get
            Return _primaryTextFontSize
        End Get
        Set(ByVal value As Single)
            _primaryTextFontSize = value
        End Set
    End Property

    ''' <summary>
    ''' PrimaryTextFontStyle
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Property PrimaryTextFontStyle() As System.Drawing.FontStyle
        Get
            Return _primaryTextFontStyle
        End Get
        Set(ByVal value As System.Drawing.FontStyle)
            _primaryTextFontStyle = value
        End Set
    End Property

    ''' <summary>
    ''' PrimaryTextForeColor
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Property PrimaryTextForeColor() As System.Drawing.Color
        Get
            Return _primaryTextForeColor
        End Get
        Set(ByVal value As System.Drawing.Color)
            _primaryTextForeColor = value
        End Set
    End Property

    ''' <summary>
    ''' PrimaryTextBackColor
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Property PrimaryTextBackColor() As System.Drawing.Color
        Get
            Return _primaryTextBackColor
        End Get
        Set(ByVal value As System.Drawing.Color)
            _primaryTextBackColor = value
        End Set
    End Property

    ''' <summary>
    ''' PrimaryTextAlignment
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Property PrimaryTextAlignment() As System.Drawing.StringAlignment
        Get
            Return _primaryTextAlignment
        End Get
        Set(ByVal value As System.Drawing.StringAlignment)
            _primaryTextAlignment = value
        End Set
    End Property

    ''' <summary>
    ''' URL Text
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Property URLText() As String
        Get
            Return _urlTextText
        End Get
        Set(ByVal value As String)
            _urlTextText = value
        End Set
    End Property

    ''' <summary>
    ''' URLTextFontName
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Property URLTextFontName() As String
        Get
            Return _urlTextTextFontName
        End Get
        Set(ByVal value As String)
            _urlTextTextFontName = value
        End Set
    End Property

    ''' <summary>
    ''' URLTextFontSize
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Property URLTextFontSize() As Single
        Get
            Return _urlTextTextFontSize
        End Get
        Set(ByVal value As Single)
            _urlTextTextFontSize = value
        End Set
    End Property

    ''' <summary>
    ''' URLTextFontStyle
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Property URLTextFontStyle() As System.Drawing.FontStyle
        Get
            Return _urlTextTextFontStyle
        End Get
        Set(ByVal value As System.Drawing.FontStyle)
            _urlTextTextFontStyle = value
        End Set
    End Property

    ''' <summary>
    ''' URLTextForeColor
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Property URLTextForeColor() As System.Drawing.Color
        Get
            Return _urlTextTextForeColor
        End Get
        Set(ByVal value As System.Drawing.Color)
            _urlTextTextForeColor = value
        End Set
    End Property

    ''' <summary>
    ''' URLTextBackColor
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Property URLTextBackColor() As System.Drawing.Color
        Get
            Return _urlTextTextBackColor
        End Get
        Set(ByVal value As System.Drawing.Color)
            _urlTextTextBackColor = value
        End Set
    End Property

    ''' <summary>
    ''' URLTextAlignment
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Property URLTextAlignment() As System.Drawing.StringAlignment
        Get
            Return _urlTextTextAlignment
        End Get
        Set(ByVal value As System.Drawing.StringAlignment)
            _urlTextTextAlignment = value
        End Set
    End Property

    ''' <summary>
    ''' iThumbnailLeft
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    <CLSCompliant(False)> _
    Public Property iThumbnailLeft() As Microsoft.Drawing.IImage
        Get
            Return _iThumbnailLeft
        End Get
        Set(ByVal value As Microsoft.Drawing.IImage)
            _iThumbnailLeft = value
        End Set
    End Property

    ''' <summary>
    ''' iThumbnailRight
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    <CLSCompliant(False)> _
    Public Property iThumbnailRight() As Microsoft.Drawing.IImage
        Get
            Return _iThumbnailRight
        End Get
        Set(ByVal value As Microsoft.Drawing.IImage)
            _iThumbnailRight = value
        End Set
    End Property

#End Region

End Class